package singleton;

import java.io.ObjectStreamException;
import java.io.Serializable;

/**
 * @功能
 * @创建时间 2020/5/3
 */
public class Single3 implements Serializable {
    private static  Single3 single;

    private Single3() {
        if(single!=null)
            throw new RuntimeException();

    }
    public static synchronized Single3 create(){
        if(single==null){
            single=new Single3();
        }
        return single;
    }
    //防止反序列一个新对象
    private Object readResolve() throws ObjectStreamException
    {
        return single;
    }
}
